﻿
using UnityEngine;
using UnityEngine.UI;

/// <summary>
/// Makes it possible to animate alpha of the widget or a panel.
/// </summary>

[RequireComponent(typeof(Graphic))]
[ExecuteInEditMode]
public class UGUIAnimatedAlpha : MonoBehaviour
{
	[Range(0f, 1f)]
	public float alpha = 1f;

    Graphic mWidget;

	void OnEnable ()
	{
		mWidget = GetComponent<Graphic>();
		LateUpdate();
	}

	void LateUpdate ()
	{
        Color c = mWidget.color;
        c.a = alpha;

        mWidget.color = c;
    }
}
